'use strict';
const md5 = require('md5');
module.exports = (sequelize, Sequelize) => {
  const Users = sequelize.define('user', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER
    },
    username: {
      type: Sequelize.STRING(50),
      unique: true,
      allowNull: false,
      defaultValue: ''
    },
    password: {
      type: Sequelize.CHAR(32),
      allowNull: false,
      defaultValue: ''
    },
    disable: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: false
    },
    userimg: {
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: false
    },
    createdAt: {
      allowNull: false,
      type: Sequelize.DATE,
      field: 'created_at'
    },
    updatedAt: {
      allowNull: false,
      type: Sequelize.DATE,
      field: 'updated_at'
    }
  }, {
      tableName: 'user',
      charset: 'utf8mb4',
      collate: 'utf8mb4_bin'
  });
  Users.associate = function (models) {
    this.hasOne(models['profile']);
    this.hasMany(models['favorite']);
    this.hasMany(models['score']);
    this.hasMany(models['cookbook']);
    this.hasMany(models['comment']);
    this.hasMany(models['comment']);
  };
  return Users;
};